package com.kungfuhacking.wristbandpro.location.presenter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.kungfuhacking.wristbandpro.R;
import com.kungfuhacking.wristbandpro.location.bean.WhiteListEntity;

import java.util.List;

/**
 * 亲情号码 adapter
 * Created by Aaron on 17/4/26.
 */

public class AffectionAdapter extends RecyclerView.Adapter<AffectionAdapter.MyViewHolder> {

    private Context context;
    private List<WhiteListEntity> affectionBeanList;

    public AffectionAdapter(Context context, List<WhiteListEntity> affectionBeanList) {
        this.context = context;
        this.affectionBeanList = affectionBeanList;
    }

    public void setAffectionBeanList(List<WhiteListEntity> affectionBeanList) {
        this.affectionBeanList = affectionBeanList;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new MyViewHolder(
                LayoutInflater.from(context).inflate(R.layout.item_affection_num, parent,
                        false));
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        holder.tv_left_item.setText(affectionBeanList.get(position).getName());
        holder.tv_right_item.setText(affectionBeanList.get(position).getPhoneNum());
    }

    @Override
    public int getItemCount() {
        return affectionBeanList.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder {

        TextView tv_left_item;
        TextView tv_right_item;

        MyViewHolder(View view) {
            super(view);
            tv_left_item = (TextView) view.findViewById(R.id.tv_left_item);
            tv_right_item = (TextView) view.findViewById(R.id.tv_right_item);
        }
    }
}
